package com.cusc.module_apply.mvvm.vm;

import android.app.Application;

import androidx.annotation.NonNull;

import com.cusc.module_apply.mvvm.model.ApplyMainNetRegister;
import com.tcgroup.phone.base_core.framework.mvvm.viewmodel.BaseRefreshViewModel;
import com.tcgroup.phone.base_core.utils.KLog;

/**
 * 作者: wangfei
 * 创建时期: 2020/4/2.
 * 包名: com.cusc.module_apply.mvvm.vm
 * 类名: OSAndroidMvvm
 */
public class ApplyFragMainViewModel extends BaseRefreshViewModel<String, ApplyMainNetRegister> {

    public ApplyFragMainViewModel(@NonNull Application application, ApplyMainNetRegister netRegister) {
        super(application, netRegister);
        enableRefresh.set(false);
        enableLoadMore.set(false);
    }

    @Override
    public void refreshData() {
        KLog.i("TAG","当前。。。");
        // postRefreshEvent(true);
        new Thread(() -> {
            //通过设置布尔值改变View
            try {
                //假设这里做了一个长时间的耗时操作
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            //通过设置布尔值改变View
            isFinishRefresh.set(true);
        }).start();
    }

    @Override
    public void loadMore() {
        new Thread(() -> {
            //通过设置布尔值改变View
            try {
                //假设这里做了一个长时间的耗时操作
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            //通过设置布尔值改变View
            isFinishLoadMore.set(true);
        }).start();
    }
}
